package iot.ht.controller.htuser;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import iot.core.annotation.Auth;
import iot.core.annotation.Log;
import iot.core.data.PageData;
import iot.core.data.BaseQto;
import iot.core.enums.AuthType;
import iot.ht.controller.htuser.data.HTUserDetailQto;
import iot.ht.controller.htuser.data.HTUserDto;
import iot.ht.controller.htuser.data.HTUserQto;
import iot.ht.controller.htuser.service.IHTUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/htuser")
@Tag(name = "用户管理", description = "")
public class HTUserController {
    @Autowired
    IHTUserService ihtUserService;

    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insertinit")
    @Operation(summary = "添加用户初始化", description = "")
    public HTUserDto insertInit(@RequestBody BaseQto qm )
    {
         return  ihtUserService.InsertInit(qm);
    }


    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/detail")
    @Operation(summary = "用户详情", description = "")
    public HTUserDto detail(@RequestBody HTUserDetailQto qm){

        return ihtUserService.Detail(qm);
    }

    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/insert")
    @Operation(summary = "添加用户", description = "")
    public  int Insert(@RequestBody HTUserDto mm){
        return ihtUserService.Insert(mm);
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/update")
    @Operation(summary = "修改用户", description = "")
    public  int Update(@RequestBody HTUserDto  mm){

        return ihtUserService.Update(mm);
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/delete")
    @Operation(summary = "删除用户", description = "")
    public  int Delete(@RequestBody BaseQto mm){
        return ihtUserService.delete(mm);
    }

    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/qy")
    @Operation(summary = "启用用户", description = "")
    public  int QY(@RequestBody BaseQto mm){

        return ihtUserService.QY(mm);
    }


    @Auth(authType = AuthType.Auth)
    @Log(logNeed = true,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/ty")
    @Operation(summary = "停用用户", description = "")
    public  int TY(@RequestBody BaseQto mm){

        return ihtUserService.TY(mm);
    }

    @Auth(authType = AuthType.Login)
    @Log(logNeed = false,logTemplete ="",logPin = true,logPout = true)
    @PostMapping("/page")
    @Operation(summary = "用户分页", description = "")
    public  PageData<HTUserDto> page(@RequestBody HTUserQto mm){

        return ihtUserService.Page(mm);
    }




}
